package com.futures.questionbank.fragment;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.futures.questionbank.R;
import com.futures.questionbank.adapter.BaseViewHolder;
import com.futures.questionbank.adapter.SectionAdpter2;
import com.futures.questionbank.db.table.zixun;
import com.raizlabs.android.dbflow.sql.language.SQLite;

import java.util.ArrayList;
import java.util.List;

/**
 * author : huang
 * date   : 2020/6/28 0028 14:57
 * version: 1.0
 */
public class OrderSettlementFragment3 extends com.futures.questionbank.base.BaseFragment {
    private RecyclerView rv;
    private List<zixun> zixuns = new ArrayList<>();
    @Override
    protected int getLayoutResource() {
        return R.layout.order_fragment;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
    }

    private void initView() {

        List<zixun> sections1 = SQLite.select().
                from(zixun.class).queryList();

        for (zixun zixun : sections1) {
            if (zixun.getId() > 17){
                zixuns.add(zixun);
            }
        }

        rv =  rootView.findViewById(R.id.rv);
        rv.setLayoutManager(new LinearLayoutManager(getActivity()));
        //设置Item增加、移除动画
        rv.setItemAnimator(new DefaultItemAnimator());
        SectionAdpter2 chapterAdpter = new SectionAdpter2(getActivity(), zixuns, new TypeItemListener());
        rv.setAdapter(chapterAdpter);
    }


    class TypeItemListener implements BaseViewHolder.onItemCommonClickListener {
        @Override
        public void onItemClickListener(int position) {
            Intent intent = new Intent();
            // intent.putExtra("index", sections1.get(position).getExam_id());
            // intent.setClass(SectionActivity.this, ExamActivity.class);
            startActivity(intent);
        }

        @Override
        public void onItemLongClickListener(int position) {

        }
    }
}
